/*
 * Copyright 2004-2006 asoft
 * 本软件及其所有拷贝的名称，与光盘上或本软件中注明的公司同在。
 * 本软件及文档享有版权，并受国家版权法及国际协约条款的保护。
 * 您不可以从本软件中去掉其版权声明；并保证为本软件的拷贝（本部或部分）复制版权声明。
 * 您同意制止以任何形式非法拷贝本软件及文档。
 * 版权信息参见：
 *      http://www.asoft.cn/licenses
 */

package com.asoft.common.sysframe.service;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;

import com.asoft.common.base.web.service.AbstractListService;
import com.asoft.common.sysframe.manager.UserManager;
import com.asoft.common.sysframe.view.foreveryone.UserList4EveryOne;

/**
 * <p>Title: 人员</p>
 * <p>Description: 人员 User </p>
 * <p>Copyright: Copyright (c) 2004-2006</p>
 * <p>Company: asoft</p>
 * @ $Author: amon.lei $
 * @ $Date: 2007-2-20 $
 * @ $Revision: 1.0 $
 * @ created in 2007-2-20
 *
 */

public class FindUsersService extends AbstractListService
{
        static Logger logger = Logger.getLogger(FindUsersService.class);

        private UserManager userManager;

        public void setUserManager(UserManager userManager)
        {
                this.userManager = userManager;
        }

        /** 获取列表的models */
        public List getList(HttpServletRequest request)
        {
                // 获取翻页结果集合
                logger.debug("1. 获取查询条件.....");
                // 获取查询条件
                String orgId = this.getValueFromRequestParameter(request,"orgId");
                String roleId = this.getValueFromRequestParameter(request,"roleId");
                String postId = this.getValueFromRequestParameter(request,"postId");
                String account = this.getValueFromRequestParameter(request,"account");
                String name = this.getValueFromRequestParameter(request,"name");
                String address = this.getValueFromRequestParameter(request,"address");
                String email = this.getValueFromRequestParameter(request,"email");
                String phone = this.getValueFromRequestParameter(request,"phone");
                String homeSite = this.getValueFromRequestParameter(request,"homeSite");
                String mobile = this.getValueFromRequestParameter(request,"mobile");
                String status = this.getValueFromRequestParameter(request,"status");

                String orderBy = this.getValueFromRequestParameter(request,"orderBy","user.pri");
                String sortType = this.getValueFromRequestParameter(request,"sortType","asc");
                logger.debug("2. 获取查询条件完毕,开始查询.....");
                return this.userManager.findUsers(orgId,
                                                  roleId,
                                                  postId,
                                                  account,
                                                  name,
                                                  address,
                                                  email,
                                                  phone,
                                                  homeSite,
                                                  mobile,
                                                  status,
                                                  orderBy,
                                                  sortType);
        }

        /** model -> viewer */
        public Object getViewer(HttpServletRequest request)
        {
                // 根据request里面提供的参数做角色、权限判断,然后返回对应的viewer
                return new UserList4EveryOne(); // foreveryone
        }

}
